<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
    <META http-equiv=Content-Type content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="/sys/resources/css/reset.css" type="text/css" media="screen"/>
    <link rel="stylesheet" href="/sys/resources/css/style.css" type="text/css" media="screen"/>
    <link rel="stylesheet" href="/sys/resources/css/invalid.css" type="text/css" media="screen"/>
    <link rel="stylesheet" href="/sys/resources/css/bootstrap.css" type="text/css" media="screen"/>
    <link rel="stylesheet" href="/sys/resources/css/bootstrap-datetimepicker.min.css" type="text/css" media="screen"/>

    <script type="text/javascript" src="/sys/resources/scripts/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="/sys/resources/scripts/zhTable.js"></script>
    <script type="text/javascript" src="/sys/resources/scripts/bootstrap.js"></script>
    <script type="text/javascript" src="/sys/resources/scripts/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="/sys/resources/scripts/bootstrap-datetimepicker.zh-CN.js"></script>


    <script type="text/javascript" src="/sys/resources/scripts/simpla.jquery.configuration.js"></script>
    <script type="text/javascript" src="/sys/resources/scripts/facebox.js"></script>

    <title>指定课程</title>
    <script >
        var distributePageUrl = "/sys/curriculum/distributePage.do";
        var checkCurrUrl = "/sys/curriculum/getUserCurr.do";
        //查看用户所有的课程
        function checkCurr(uid){
            if(uid != null && !isNaN(uid))
            {
                $.ajax({
                    type: "POST",
                    url: checkCurrUrl,
                    data: {uid:uid},
                    success: function (data) {
                        var content = $("#myModal .modal-content tbody");
                        content.html("");
                        var list = data.list;
                        var trs = "";
                        if(list != null && list.length > 0)
                        {

                            for(var i=0; i<list.length;i++)
                            {

                                var ff = "未完成"
                                if(list[i].isfinished =='1')
                                {
                                    ff="完成"
                                }
                                trs = trs + "<tr>";
                                trs = trs + "<td>"+list[i].title+"</td>";
                                trs = trs + "<td>"+ff+"</td>";
                                trs = trs + "<td>"+list[i].score+"</td>";
                                trs = trs + "<td>"+list[i].obtainScore+"</td>";
                                trs = trs + "<td>"+list[i].testtime+"</td>";
                                trs = trs + "<td>"+list[i].content+"</td>";
                                trs = trs + "</tr>";
                            }
                            content.html(trs);
                            $("#myModal").modal('show');
                        }
                        else{
                            alert("该用户还未指定课程");
                        }

                    }
                });
            }
        }
        function initData(tds,data,index)
        {
            $(tds[0]).html("<input type='checkbox' value='"+data.uid+"'>");
            $(tds[1]).html(data.passport);
            $(tds[2]).html(data.realname);
            $(tds[3]).html(data.roleName);

            var sta = "屏蔽";
            if(data.status=="1")
            {
                sta = "正常";
            }
            $(tds[4]).html(sta);
            var oper = "<button class='bottom btn-primary btn-sm' onclick='checkCurr("+data.uid+")'>查看课程情况</button>"
            $(tds[5]).html(oper);
        }
        var zhTable = null;
        $(function () {
            //初始化table的js，
            //$("#tablePageDiv") 指定操作div ，
            //initData 填充数据的方法
            //true 页面初始化时加载数据
            zhTable = new initZhTable($("#tablePageDiv"), initData,true);


            //初始化时间插件
            $('.form_datetime').datetimepicker({
                format: 'yyyy-mm-dd',
                language: 'zh-CN',
                weekStart: 1,
                todayBtn: 1,
                autoclose: 1,
                todayHighlight: 1,
                startView: 2,
                minView: 2,
                forceParse: 0
            }).click(function () {
                $(this).val("");
            });
        });

        function deleteDate() {
            var ids = zhTable.getAllChecked();
            if(ids == null || ids == "")
            {
                alert("请选择数据");
                return;
            }

            location.href = distributePageUrl+"?ids="+ids;//转到分配课程页面
        }
    </script>

</HEAD>
<BODY class="mian_bg">
<TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
    <TR height=28>
        <TD class="addr_td">&nbsp;&nbsp;<img src="/sys/resources/images/addr_icon.png">&nbsp;当前位置: 学习>人员学习管理>指定课程</TD>
    </TR>
    <TR>
        <TD bgColor=#7ca600 height=1></TD>
    </TR>
    <TR>
        <TD bgColor=#8ebe00 height=1></TD>
    </TR>
</TABLE>

<div class="container">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">指定课程</h3>
        </div>
        <div class="panel-body">
            <div id="tablePageDiv">
                <div id="searchDiv">
                    <form name="searchDivForm" url="/sys/curriculum/distributeQuery.do">
                        <div class="row">
                            <div class="col-xs-4">
                                <div class="input-group">
                                    <span class="input-group-addon">用户名</span>
                                    <input type="text" name="passport" value="" class="form-control">
                                </div>
                            </div>

                            <div class="col-xs-4">
                                <div class="input-group">
                                    <span class="input-group-addon">真实姓名</span>
                                    <input type="text" name="realname" value="" class="form-control">
                                </div>
                            </div>

                            <div class="col-xs-4">
                                <div class="input-group">
                                    <span class="input-group-addon">注册日期</span>
                                    <input type="text" name="regtime" value="" readonly class="form_datetime form-control">
                                </div>
                            </div>

                        </div>

                        <div class="row" style="margin-top: 7px;">
                            <div class="col-xs-1">
                                <button type="button" class="btn btn-success btn-block searchBtn">查询</button>
                            </div>

                            <div class="col-xs-1">
                                <button type="button" onclick="deleteDate();" class="btn btn-success btn-block">指定课程</button>
                            </div>

                        </div>
                    </form>
                </div>

                <div id="tableDiv" style="margin-top: 10px;">
                    <table class="table table-hover table-bordered .table-condensed">
                        <thead>
                        <tr  class="bg-success">
                            <th style="width: 60px;"><input class="checkAll" type="checkbox"/>全选</th>
                            <th>用户名</th>
                            <th>真实姓名</th>
                            <th>角色</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>

                        </tbody>
                    </table>
                    <ul class="pagination">

                    </ul>
                </div>
            </div>
        </div>
    </div>

    <div id="myModal" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content" style="padding: 5px;">
                <table class="table table-bordered table-striped">
                    <thead>
                    <tr  class="bg-success">
                        <th>标题</th>
                        <th>学习是否完成</th>
                        <th>满分分数</th>
                        <th>考试得分</th>
                        <th>考试时间</th>
                        <th>简介</th>
                    </tr>
                    </thead>
                    <tbody>

                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
</BODY>
</HTML>